
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Tester.java
 *
 * Created on 22/07/2011, 17:51:53
 */



/**
 *
 * @author Victor
 */
public class Tester extends javax.swing.JFrame {

    /**
	 * 
	 */
	private static final long serialVersionUID = -5012942523733360000L;
	/** Creates new form Tester */
    public Tester() {
        initComponents();
        WindowAdapter oyenteCierraVentana = new java.awt.event.WindowAdapter() {
                public void windowClosing (WindowEvent e) {
                        this_windowClosing(e);
                }
        };
        this.addWindowListener(oyenteCierraVentana);
    }

    private void salir(){
        if (JOptionPane.showConfirmDialog(null, "Esta seguro que desea salir?"
            ,"Importante",JOptionPane.OK_CANCEL_OPTION) ==0){
                    System.exit(0);
            }
    }

    public void this_windowClosing(WindowEvent e) {
           salir();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPInferior = new javax.swing.JPanel();
        jlLink = new javax.swing.JLabel();
        botonSalir = new javax.swing.JButton();
        jTPestanias = new javax.swing.JTabbedPane();
        panelPerformance = new Performance();
        panelControlRemoto = new ControlRemoto();
        panelConector = new PanelConector();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(".:: iRobot ::. - Tester");
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/favicon.png")).getImage());
        setResizable(false);

        jPInferior.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jlLink.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IE9_24.png"))); // NOI18N
        jlLink.setText("<html><a href=\\\"http://Project-iRobot.com.ar\">http://Project-iRobot.com.ar</a></html>");
        jlLink.setToolTipText("Abre el Blog en tu navegador favorito");
        jlLink.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jlLink.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jlLinkMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jlLinkMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jlLinkMouseExited(evt);
            }
        });

        botonSalir.setText("Salir");
        botonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPInferiorLayout = new javax.swing.GroupLayout(jPInferior);
        jPInferior.setLayout(jPInferiorLayout);
        jPInferiorLayout.setHorizontalGroup(
            jPInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPInferiorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jlLink, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 490, Short.MAX_VALUE)
                .addComponent(botonSalir)
                .addContainerGap())
        );
        jPInferiorLayout.setVerticalGroup(
            jPInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPInferiorLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPInferiorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlLink, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonSalir))
                .addContainerGap())
        );

        jTPestanias.addTab("Performance", panelPerformance);
        jTPestanias.addTab("Control Remoto", panelControlRemoto);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTPestanias, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 731, Short.MAX_VALUE)
                    .addComponent(panelConector, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 731, Short.MAX_VALUE)
                    .addComponent(jPInferior, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelConector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTPestanias)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPInferior, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
        salir();
    }//GEN-LAST:event_botonSalirActionPerformed

    private void jlLinkMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jlLinkMouseClicked
        if (Desktop.isDesktopSupported()) {
            Desktop desktop = Desktop.getDesktop();
            try {
                try {
                    desktop.browse(new URI("http://project-irobot.com.ar"));
                } catch (URISyntaxException e1) {
                    e1.printStackTrace();
                }
            } catch (IOException eio) {
                eio.printStackTrace();
            }
        } else {
        }
    }//GEN-LAST:event_jlLinkMouseClicked

    private void jlLinkMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jlLinkMouseEntered
        rc = jlLink.getForeground();
        jlLink.setForeground(Color.blue);
    }//GEN-LAST:event_jlLinkMouseEntered

    private void jlLinkMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jlLinkMouseExited
        jlLink.setForeground(rc);
    }//GEN-LAST:event_jlLinkMouseExited

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Tester ventana = new Tester();
                ventana.pack();
                ventana.setVisible(true);
                ventana.setLocationRelativeTo(null);
            }
        });
    }

 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonSalir;
    private javax.swing.JPanel jPInferior;
    private javax.swing.JTabbedPane jTPestanias;
    private javax.swing.JLabel jlLink;
    private PanelConector panelConector;
    private ControlRemoto panelControlRemoto;
    private Performance panelPerformance;
    // End of variables declaration//GEN-END:variables
    private Color rc;
}
